package org.kongqian.marketing.service.impl;

import org.kongqian.marketing.domain.Activity;
import org.kongqian.marketing.domain.ActivityRemark;
import org.kongqian.marketing.mapper.ActivityRemarkMapper;
import org.kongqian.marketing.service.IActivityService;
import org.kongqian.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author kq
 * @since 2022-10-24
 */
@Service
public class ActivityServiceImpl extends BaseServiceImpl<Activity> implements IActivityService {

    @Autowired
    private ActivityRemarkMapper activityRemarkMapper;
    @Override
    public void insert(Activity activity) {
        activity.setCreate_time(new Date());
        super.insert(activity);
        ActivityRemark activityRemark = new ActivityRemark();
        activityRemark.setNote_content(activity.getName()+":新增操作");
        activityRemarkMapper.insert(activityRemark);
    }

    @Override
    public void updateById(Activity activity) {
        activity.setEdit_time(new Date());
        super.updateById(activity);
        ActivityRemark activityRemark = new ActivityRemark();
        activityRemark.setNote_content(activity.getName()+":新增操作");
        activityRemark.setId(activity.getId());
        activityRemarkMapper.updateById(activityRemark);
    }
}
